﻿public class DataCaches
{
    public static ltModel.Model.article_user GetUser(int userId)
    {
        string key = "user_" + userId.ToString();
        ltModel.Model.article_user user = ObjectCache.Get<ltModel.Model.article_user>(key);
        if (user == null)
        {
            user = new ltModel.BLL.article_user().GetModel(userId);
            ObjectCache.Set(key, user);
        }
        return user;
    }

    public static ltModel.Model.userTeam GetUserTeam(bool isManager, int id)
    {
        string key = "team_" + id.ToString();
        ltModel.Model.userTeam team = ObjectCache.Get<ltModel.Model.userTeam>(key);
        if (team == null)
        {
            if (isManager)
            {
                team = new ltModel.Model.userTeam();
                team.sh = team.tj = team.add = team.del = "1";
            }
            else
                team = new ltModel.BLL.userTeam().GetModel(id);
            ObjectCache.Set(key, team);
        }
        return team;
    }

    public static void SetUser(int userId, ltModel.Model.article_user user)
    {
        string key = "user_" + userId.ToString();
        ObjectCache.Set(key, user);
    }

    public static void SetUserTeam(int id, ltModel.Model.userTeam team)
    {
        string key = "team_" + id.ToString();
        ObjectCache.Set(key, team);
    }
}